﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Pozr
{
    public partial class ControlSettings : UserControl
    {
        public ControlSettings()
        {
            InitializeComponent();
        }

        public void InitSettings()
        {
            try
            {
                object temp;
                if ((temp = Middleware.Settings.GetSetting("Autostart", "GPS")) != null)
                    this.cbGps.Checked = (bool)temp;
                if ((temp = Middleware.Settings.GetSetting("Autostart", "Cell")) != null)
                    this.cbCell.Checked = (bool)temp;
                if ((temp = Middleware.Settings.GetSetting("Autostart", "Wifi")) != null)
                    this.cbWifi.Checked = (bool)temp;
                if ((temp = Middleware.Settings.GetSetting("Autostart", "Bluetooth")) != null)
                    this.cbBluetooth.Checked = (bool)temp;
 //               if ((temp = Middleware.Settings.GetSetting("PositionHandler", "GpsCacheInterval")) != null)
 //                   this.numericCacheInterval.Value = (decimal)temp;
            }
            catch (Exception e)
            {
                Middleware.WriteLog(e.Message);
            }
        }

        private void cbAutostart_CheckStateChanged(object sender, EventArgs e)
        {
            Middleware.Settings.ModifySetting("Autostart", ((CheckBox)sender).Text, ((CheckBox)sender).Checked);
        }

        private void buttonTest_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void buttonTest2_Click(object sender, EventArgs e)
        {
            Middleware.PositionHandler.RequestData(Interfaces.PositionOriginator.Cell);
        }
    }
}
